#include "SQLCommentStatement.h"

SQLCommentStatement_Type_ptr SQLCommentStatement_Type::TABLE = SQLCommentStatement_Type_ptr(new SQLCommentStatement_Type(1ULL << 0, make_string_ptr("TABLE")));
SQLCommentStatement_Type_ptr SQLCommentStatement_Type::COLUMN = SQLCommentStatement_Type_ptr(new SQLCommentStatement_Type(1ULL << 1, make_string_ptr("COLUMN")));
SQLCommentStatement_Type_ptr SQLCommentStatement_Type::INDEX = SQLCommentStatement_Type_ptr(new SQLCommentStatement_Type(1ULL << 2, make_string_ptr("INDEX")));
SQLCommentStatement_Type_ptr SQLCommentStatement_Type::VIEW = SQLCommentStatement_Type_ptr(new SQLCommentStatement_Type(1ULL << 3, make_string_ptr("VIEW")));
SQLCommentStatement_Type::SQLCommentStatement_Type(uint64_t mask, string_ptr name)
{
  this->mask = mask;
  this->name = name;
}

SQLExpr_ptr SQLCommentStatement::getComment()
{
  return comment;
}

void SQLCommentStatement::setComment(SQLExpr_ptr comment)
{
  this->comment = comment;
}

SQLCommentStatement_Type_ptr SQLCommentStatement::getType()
{
  return type;
}

void SQLCommentStatement::setType(SQLCommentStatement_Type_ptr type)
{
  this->type = type;
}

SQLExprTableSource_ptr SQLCommentStatement::getOn()
{
  return on;
}

void SQLCommentStatement::setOn(SQLExprTableSource_ptr on)
{
  if (on != NULL)
  {
    on->setParent(SharedObject(SQLCommentStatement));
  }
  this->on = on;
}

void SQLCommentStatement::setOn(SQLName_ptr on)
{
  this->setOn(std::dynamic_pointer_cast<SQLExprTableSource>(on));
}

// void SQLCommentStatement::accept0(SQLASTVisitor_ptr visitor) {
//     if (visitor->visit(this)) {
//         acceptChild(visitor, on);
//         acceptChild(visitor, comment);
//     }
//     visitor->endVisit(this);
// }

SQLObject_list_ptr SQLCommentStatement::getChildren()
{
  SQLObject_list_ptr children = std::make_shared<std::list<SQLObject_ptr>>();
  if (on != nullptr)
  {
    children->push_back(on);
  }
  if (comment != NULL)
  {
    children->push_back(comment);
  }
  return children;
}
